<template>
  <Module-box title="新增报修工单提醒" height="612px" bg="long2">
    <G-table id="wx" :columns="columns" :data="dataList" :speed="3" hover height="539" />
  </Module-box>
</template>
<script>
import { getWarrantyReminder } from "@/utils/screen";
export default {
  data() {
    return {
      columns: [
        { label: "工单ID", prop: "workID", align: "left", width: 80 },
        {
          label: "客户名称",
          align: "left",
          scroll: false,
          default: (row, column) => {
            let text;
            if (column.scroll) {
              text = row.hospitalName || "-";
            } else {
              let frist = row.hospitalName ? row.hospitalName[0] : "";
              text = frist ? frist + "*".repeat(row.hospitalName.length - 1) : "-";
            }
            return text;
          },
        },
        { label: "设备品牌", prop: "oneClassName", align: "left" },
        { label: "型号", prop: "threeClassName", align: "left" },
        // { label: "序列号", prop: "serial", align: "left" },
        { label: "故障现象", prop: "describe", align: "left" },
        {
          label: "指派工程师",
          prop: "engineer",
          align: "left",
          color: (row) =>
            !row.engineer
              ? "linear-gradient(180deg, #FFF2F2 0%, #FF1418 100%)"
              : "#C5E0FE",
          default: "未指派",
        },
        {
          label: "销售",
          align: "left",
          prop: "sale",
          color: (row) =>
            !row.sale ? "linear-gradient(180deg, #FFF2F2 0%, #FF1418 100%)" : "#C5E0FE",
          default: "未指派",
        },
        {
          label: "状态标签",
          prop: "statusStr",
          align: "left",
          width: 200,
          color: "linear-gradient(180deg, #FFF2F2 0%, #FF1418 100%)",
        },
        { label: "物流单号", prop: "logisticsNumber", align: "left" },
      ],
      dataList: [], // 数据列表
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    // 获取报修工单提醒列表
    getList() {
      getWarrantyReminder().then((res) => {
        if (res && res.code == 1) {
          this.dataList = res.data;
          if (this.dataList.length > 0) {
            let ring = this.dataList.some(
              (i) =>
                i.engineer == null || i.engineer == "" || i.sale == null || i.sale == ""
            );
            this.$emit("ring", ring);
          }
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped></style>
